package com.yinhai.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import android.content.Context;

import com.tgb.lk.ahibernate.dao.impl.BaseDaoImpl;
import com.yinhai.dao.IMUserGroupDaoImpl;
import com.yinhai.model.IMUserGroup;
import com.yinhai.util.DBHelper;
public class IMUserGroupServiceImpl {
	private Context context;
	private IMUserGroupDaoImpl imUserGroupDao;
	public IMUserGroupServiceImpl(Context context) {
		this.context = context;
		imUserGroupDao = new IMUserGroupDaoImpl(context);
	}

	/**
	 * 根据分组ID获取分组成员
	 * @param groupId
	 * @return
	 */
	public List<IMUserGroup> findByGroupId(String groupId) {
		String sql = "select u.* from im_user_group_test u where u.group_id='"+groupId+"'";
		return imUserGroupDao.rawQuery(sql, null);
	}
	
	public void insert(IMUserGroup u) {
		imUserGroupDao.insert(u);
	}
	
	public void deleteUserGroup(String groupId) {
		String sql = "delete from im_user_group_test where group_id='"+groupId+"'";
		imUserGroupDao.execSql(sql, null);
	}
	public void deleteUserGroup() {
		String sql = "delete from im_user_group_test";
		imUserGroupDao.execSql(sql, null);
	}
	
	public List<Map<String,String>> findMapByGroupId(String groupId) {
		String sql = "select user_id ,user_name  from im_user_group_test where group_id='"+groupId+"'";
		return imUserGroupDao.query2MapList(sql, null);
	}
	
}
